﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wook3_lcm
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入第一个整数：");
            int num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("请输入第二个整数：");
            int num2 = Convert.ToInt32(Console.ReadLine());
            if (num1 * num2 != 0)
            {
                Program lcm = new Program();
                Console.WriteLine("{0}和{1}的最小公倍数为：{2}", num1, num2, lcm.LCM(num1, num2));
            }
            else
                Console.WriteLine("输入0没有意义");
            Console.ReadKey();
        }
        public float LCM(int n1, int n2)
        {
            int temp = Math.Max(n1, n2);
            n2 = Math.Min(n1, n2);
            n1 = temp;
            int sum = n1 * n2;
            while (n2 != 0)
            {
                int m = n1 % n2;
                n1 = n2;
                n2 = m;
            }
            return (sum / n1);
        }
    }
       
}
